﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Microsoft.Rtc.Collaboration.Samples.HTMLPresenceControls.Service.Common;

namespace Microsoft.Rtc.Collaboration.Samples.HTMLPresenceControls.Samples
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.ClientScript.GetWebResourceUrl(
                typeof(Microsoft.Rtc.Collaboration.Samples.HTMLPresenceControls.Controls.PresenceIndicator),
                "Microsoft.Rtc.Collaboration.Samples.HTMLPresenceControls.Controls.Scripts.jquery.timers-1.2.js");

            try
            {
                if (!Page.IsPostBack)
                {
                    LoadAccounts();
                }
            }
            catch (Exception ex) 
            {
                throw ex;
            }
        }

        protected void LoadAccounts()
        {
            var accounts = new List<Account>();

            accounts.Add(new Account() 
            {
                AccountName = "General Industries",
                AccountManagerSipUri = "sip:rl@fabrikam.com",
                CustomerSince = new DateTime(2006, 05, 07),
                RevenueYTD = 456000
            });
            accounts.Add(new Account()
            {
                AccountName = "Separate Parts Corporation",
                AccountManagerSipUri = "sip:fl@fabrikam.com",
                CustomerSince = new DateTime(2009, 12, 03),
                RevenueYTD = 34000
            });
            accounts.Add(new Account()
            {
                AccountName = "Big Stores",
                AccountManagerSipUri = "sip:hd@fabrikam.com",
                CustomerSince = new DateTime(2003, 06, 17),
                RevenueYTD = 2534000
            });

            this.gvAccounts.DataSource = accounts;
            gvAccounts.DataBind();
        }
    }

    public class Account
    {
        public string AccountName { get; set; }
        public string AccountManagerSipUri { get; set; }
        public DateTime CustomerSince { get; set; }
        public Double RevenueYTD { get; set; }
    }
}